import { notification } from 'ant-design-vue';

export default class HttpResultUtil {
  static isFailure(res) {
    return !res.data.success;
  }

  static isSuccess(res) {
    return res.data.success;
  }

  static failureTipMsg(res) {
    notification.warning({
      message: '提示',
      description: res.data.msg,
    });
    return true;
  }

  static successTipMsg(res, cb?: Function) {
    if (HttpResultUtil.isSuccess(res)) {
      notification.success({
        message: '提示',
        description: res.data.msg,
      });
      if (cb) {
        cb();
      }
      return false;
    } else {
      return true;
    }
  }
}
